<?php
/**
*
* @author sunjing@shopex.cn
* @version $Id: 2019-05-13 17:23Z
*/
class erpapi_shop_response_plugins_order_tax extends erpapi_shop_response_plugins_order_abstract
{

    public function convert(erpapi_shop_response_abstract $platform)
    {
        $tax = array();
  
        if ($platform->_ordersdf['invoice_amount']>0){
            $tax['total_amount'] = $platform->_ordersdf['total_amount'];
            $tax['invoice_amount'] = $platform->_ordersdf['invoice_amount'];
        }

      return $tax;
    }

    /**
     *
     * @return void
     * @author 
     **/
    public function postCreate($order_id,$tax)
    {

        if ($tax['invoice_amount']>0){
            $service_price = bcsub($tax['total_amount'], $tax['invoice_amount'],3);
 
            kernel::database()->exec("UPDATE sdb_ome_orders SET service_price=".$service_price.",invoice_amount=".$tax['invoice_amount']." WHERE order_id=".$order_id);
            
            
        }


    }
}
